package com.fujimana.android.manacode.loalder;

import java.util.ArrayList;
import java.util.List;

public class Tree<T> {

	public List<Tree<T>> childlen;

	private Tree<T> parent;

	private T value;

	public Tree(Tree<T> parent) {
		this.parent = parent;
		this.childlen = new ArrayList<Tree<T>>();
	}

	public void addChild(Tree<T> tree) {
		this.childlen.add(tree);
	}

	public List<Tree<T>> getChildlen() {
		return childlen;
	}

	public void setChildlen(List<Tree<T>> childlen) {
		this.childlen = childlen;
	}

	public Tree<T> getParent() {
		return parent;
	}

	public void setParent(Tree<T> parent) {
		this.parent = parent;
	}

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public boolean isRoot() {
		return this.parent == null;
	}

	@Override
	public String toString() {
		return this.getValue().toString();
	}

}
